﻿<local:LayoutAwarePage
    x:Class="yavc.Metro.Pages.AddDevicePage"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:yavc.Metro.Pages"
    xmlns:con="using:yavc.Metro.Controls"
    xmlns:conv="using:yavc.Metro.Converters">

    <Grid Background="{StaticResource MetroBackgroundBrush}">
        <Grid.Resources>
            <conv:ScaleValue x:Key="scale" x:Name="theScale" Value="{Binding Value, Source={StaticResource BaseValue}, Mode=TwoWay}" />
            <conv:ScaleConverter x:Key="addDevScaleConv" BaseValue="100" />
            <x:Double x:Key="blockWidth">0.35</x:Double>
            <x:Double x:Key="boxWidth">0.55</x:Double>
            <x:Double x:Key="tbHeight">0.1</x:Double>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <con:HeaderControl HeaderText="Yamaha AV Controller" SubHeaderText="Add Device" 
                           HeaderFontSize="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource convMetroTitleFontSize}}"
                           SubHeaderFontSize="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource convMetroTextLargeFontSize}}" />
        
        <con:BackControl VerticalAlignment="Top" Margin="0" />
        
        <StackPanel VerticalAlignment="Top" Orientation="Vertical" HorizontalAlignment="Center" Grid.Row="1" Margin="10">
            <StackPanel.Resources>
                <Style TargetType="StackPanel">
                    <Setter Property="Orientation" Value="Horizontal" />
                </Style>
                <Style TargetType="TextBlock">
                    <Setter Property="Margin" Value="10" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                </Style>
                <Style TargetType="TextBox">
                    <Setter Property="Margin" Value="10" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                </Style>
            </StackPanel.Resources>
            <StackPanel>
                <TextBlock Text="IP or Hostname:" 
                           FontSize="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource convMetroTextLargeFontSize}}" 
                           Height="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource tbHeight}}" 
                           Width="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource blockWidth}}" />
                <TextBox x:Name="tbIP" 
                         FontSize="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource convMetroTextLargeFontSize}}" 
                         Height="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource tbHeight}}" 
                         Width="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource boxWidth}}" />
            </StackPanel>
            <StackPanel>
                <TextBlock Text="Friendly Name:" 
                           FontSize="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource convMetroTextLargeFontSize}}" 
                           Height="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource tbHeight}}" 
                           Width="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource blockWidth}}" />
                <TextBox x:Name="tbFriendlyName" 
                         FontSize="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource convMetroTextLargeFontSize}}"
                         Height="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource tbHeight}}" 
                         Width="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter={StaticResource boxWidth}}" />
            </StackPanel>
            
            <Button Content="Try to Add" Click="ButtonTryAdd_Click" HorizontalAlignment="Center"
                    Width="{Binding Source={StaticResource scale}, Path=Value, Converter={StaticResource addDevScaleConv}, ConverterParameter=0.8}"
                    Margin="10" />
        </StackPanel>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetProperty="Value" Storyboard.TargetName="theScale" 
                                         To="{Binding Source={StaticResource DefaultFullScreenLandscapeScale}}" 
                                         EnableDependentAnimation="True"
                                         Duration="0:0:0.25" />
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Filled" />
                <VisualState x:Name="FullScreenPortrait" />
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetProperty="Value" Storyboard.TargetName="theScale" 
                                         To="2.8" 
                                         EnableDependentAnimation="True"
                                         Duration="0:0:0.25" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</local:LayoutAwarePage>